package edu.kjxy.day03.doubleSynBlackOneTwo;

/**
 * 功能:
 * 作者:程序员欧阳子韩
 * 日期:2024/2/2 18:36
 */
public class ObjectService {
    public void serviceMethodA() {
        try {
            synchronized (this){
                System.out.println("A begin time=" + System.currentTimeMillis());
                Thread.sleep(2000);
                System.out.println("A end time=" + System.currentTimeMillis());
            }
        }catch (InterruptedException e){
            e.printStackTrace();
        }
    }

    public void serviceMethodB(){
        synchronized (this){
            System.out.println("B begin time=" + System.currentTimeMillis());
            System.out.println("B end time=" + System.currentTimeMillis());
        }
    }
}
